package org.example.controller;

import org.example.service.StockJavaService;
import org.example.service.i.IStockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.support.RequestContext;

import javax.servlet.http.HttpServletRequest;

@RestController
public class StockController {

    @Autowired
    @Qualifier("stockMysqlService")
//    @Qualifier("stockJavaService")
    IStockService stockService;

    @GetMapping("stock/deduct")
    public String deduct(){
        String msg = stockService.deduct();
        System.out.println(msg);
        return msg;
    }

    @GetMapping("stock/clear")
    public String clear(){
        String msg = stockService.clear();
        System.out.println(msg);
        return msg;
    }

    @GetMapping("stock/hello")
    public String clear(HttpServletRequest request){
        String msg = "";
        msg = request.getHeader("tempUser");
        System.out.println(msg);
        return msg;
    }
}
